#ifndef PLAYINTERFACE_H
#define PLAYINTERFACE_H

#include <QMainWindow>
#include <QTextBrowser>
#include <QPushButton>
#include <QFont>
#include <QIcon>
#include <QFile>
#include <iostream>
#include <QComboBox>
#include <QListView>
#include <QPalette>
#include <QRgb>
#include <QLabel>
#include <QPropertyAnimation>

struct mapnode{
    QTextBrowser * node;
    bool exist;//该地图节点是否存在
    int x,y,type;//坐标位置，地图节点类型（地，监狱，开始，机会）
    mapnode(bool E=false,int X=0,int Y=0,int T=0):
        exist(E),x(X),y(Y),type(T){}
};

struct Player{
    QLabel * player;
    bool exist;//该玩家是否存在
    int x,y,order;//记录玩家序号,坐标
    Player(bool E=false,int X=-1000,int Y=-1000,int O=0):
        exist(E),x(X),y(Y),order(O){}
    void moveplayer(mapnode *destination,QPropertyAnimation *animation){
        animation->setDuration(5000);
        animation->setStartValue(QRect(x,y,100,100));
        animation->setEndValue(QRect(destination->x-10,destination->y,100,100));
        animation->start();
    }
};

struct landnode : public mapnode{
    QString landname;
    landnode(bool E=false,int X=0,int Y=0,int T=0,QString N=""):
        mapnode(E,X,Y,T),landname(N){}
};

namespace Ui {
class playinterface;
}

class playinterface : public QMainWindow
{
    Q_OBJECT

public:
    explicit playinterface(QWidget *parent = nullptr);
    ~playinterface();
    mapnode map[10][10];//地图二维表
    Player playerlist[9];//玩家表
    void setmap();//设置地图
    void setplayer();//设置玩家
    void move(Player *,mapnode);
private slots:
    void on_pushButton_clicked();

private:
    Ui::playinterface *ui;
    QPropertyAnimation *animation;
    QComboBox * setbackground;
    QString countrycolor,citycolor,desertcolor,icecolor,forestcolor,
    countrybordercolor,citybordercolor,desertbordercolor,icebordercolor,forestbordercolor;
};

#endif // PLAYINTERFACE_H
